ume: Add extensive documentation for user mode emulation #950
Conversation
|
@arcane-quill The language tutorial is a tutorial for the user of VADL. It has to explain how to use UME and has to include some examples. Therefore, in the tutorial there should not be any text about the implementation. So delete everything starting with |
AndreasKrall
left a comment
There was a problem hiding this comment.
Fixed typo, otherwise it is fine
51fceb6 to
479d259
Compare
There was a problem hiding this comment.
I think there are some parts missing, e.g. syscall number matching and other kinds of register definitions. E.g. using non-ABI registers, such as the actual source registers from the ISA, like X(1). Or should it only be possible to use alias registers defined in the ABI?
|
An other thing I noticed: Typically syscalls are triggered by exceptions (which are triggered by instructions). And in QEMU the execution typically checks for a specific exception and state condition to determine whether a syscall was triggered or not. Therefore, I think the Speaking of exceptions, the exception definition alone won't be sufficient to recognize a syscall. E.g. the This means the syscall trap mechanism must be a combination of an initial exception + condition check on some values. In case of However, it might be necessary to also have access to the CPU state to evaluate the condition. Unfortunately I don't have enough knowledge about different syscall mechanisms used in practice. |
It is the other way around. A syscall triggers a privileged exception changing the privilege level.
As it is the other way around, the syscall instruction does make sense and syscalls can be implemented without exceptions. Of course syscalls and exceptions are caught in privileged mode in a similar way. But in UME there is no privileged mode because the privileged mode is emulated. It is possible to implement UME without exceptions, but because the privileged exception handling is emulated and shared, they should be implemented together. For exceptions you also have to distinguish between user mode exceptions and privileged exceptions. User mode exceptions can be caught by a user mode exception handler, privileged exceptions change to privileged mode. User mode exceptions are caught be an exception handler written in assembly language which is invoked from a certain address. I believe that only few of our VADL specifications have the user mode exception handling implemented. It should be defined in the processor section. I did not look into the privileged instruction set of RISC-V to know the details. But exceptions are only implemented in a very rudimentary way in our VADL specifications.
I do not think that a specification in such a way is useful. I have to think deeper about it and read the processor documentations.
|
The trigger mechanism I was talking about was on the QEMU implementation side. In QEMU the UME is an execution loop (similar to full system emulation), where each iteration execution checks for an interrupt or exception. This means from the generator perspective, it doesn't matter which instruction causes the exception, it only matters which exception (under which condition) should be recognized as syscall. Therefore, the As we control the whole generation, we could of course also handle syscalls by defining the |
|
@arcane-quill I had a meeting with @AndreasKrall to discuss some aspects of the UME VADL definition and QEMU generation. We habe agreed on the following:
@arcane-quill If anything is unclear, please let me know. |
|
I was thinking about how to handle the syscalls, maybe we can use the specific vadl files to define the non-generic syscalls and then overwrite/add them to the existing table? Maybe we can put those existing syscalls in a separate vadl file to make it easier to generate everything correctly via the interpolation? @Jozott00 |
You mean the syscall numbers right? However, I think we should not interpolate the existing table, but render the table from scratch based on the VADL definition.
I’m not entirely sure what you mean by |
|
I just saw your suggested approach in the documentation (with the enumeration). While an enumeration would also work, it has a drawback: it lacks a declaration side type, which prevents the LSP from recognizing it as a syscall table. Consequently, the LSP cannot provide autocompletion or on-the-fly diagnostics (at least in most cases). I personally don't care that much about those features, but that is just a consideration. Of course, the benefit of such enumeration is that it’s already implemented in the frontend, so there is no need to add the syscall table definition to the language. Also you have to check if there are syscalls that need more than just the number assignment. If that is the case, the enumeration is not a sufficient type. @AndreasKrall if you are fine with enumerations for syscall tables, I am too. |
I suggest to start with the enumeration, it reuses existing constructs and we can expand it in the future, when we see that we have further requirements. |
Added section on User Mode Emulation to the tutorial.
fixed typo
9902715 to
25e47ec
Compare
This PR covers issue #764 and adds extensive documentation for the user mode emulation, including examples and descriptions for various specification cases